
#include "CDivider.h"
#include "CSubject.h"
#include <iostream>
#include <string>

using namespace std;


CDivider::CDivider(CSubject* theSubject, string theObserverName)
{
    itsSubject = theSubject;
    myObserverName = theObserverName;
    myDivisor = 1;
}


CDivider::~CDivider()
{

}


void CDivider::update()
{    
    int data = itsSubject->getData();

    cout << myObserverName << " update and calculate \t=> " << data << " / " << myDivisor << " = "  <<  data / myDivisor << endl;
}


void CDivider::setDivisor(int theValue)
{
    if (0 != theValue)
    {
        cout << myObserverName << " set divisor value to: "  << theValue << endl;
        myDivisor = theValue;
    }
    else
    {
        cout << myObserverName << " invalid divisor value"  << endl;
    }
}
